<? include "../connect.php"; ?>
<?php
ob_start();
session_start();
include "checksession.php";
date_default_timezone_set('Asia/Bangkok');

$emp_id=$_GET['emp_id'];
?>

<?
require('fpdf.php');
define('FPDF_FONTPATH','font/');

$test = $_GET['emp_id'];
class PDF extends FPDF{

	function conv($string){
	return iconv('UTF-8', 'TIS-620', $string);
	}

	function Header(){

			$this->AddFont('angsa','','angsa.php');
			$this->AddFont('angsana','B','angsab.php');
			$this->SetFont('angsana','B',10);
			$this->SetFont('angsa','',14);
			$this->Text(10,10,iconv( 'UTF-8','TIS-620',"No. 13-U................" ),0,1,"L");
			$this->Text(38,10,iconv( 'UTF-8','TIS-620',"Date/Time................................."),0,1,"L");
			$this->Text(81,10,iconv( 'UTF-8','TIS-620',"Computer ID : ........................................."),0,1,"L");
			$this->AddFont('tahoma','','tahoma.php');
	 		$this->SetFont('tahoma','',9);
			$this->Text(180,8,iconv( 'UTF-8','TIS-620',"F-IT-009 R00"),0,1,"R");
			$this->Ln(2);
		}
	
	function Footer(){
		
		$this->SetY(-0.05);
		}
}
$pdf=new PDF();
//*** Load MySQL Data ***//
include "../connect.php";
$strSQL = "SELECT * FROM employee INNER JOIN mail ON employee.emp_id = mail.emp_id where employee.emp_id ='$emp_id' order  by emp_startDate DESC";
$objQuery = mysql_query($strSQL);
mysql_query("set NAMES'TIS620'");
$resultData = array();
for ($i=0;$i<mysql_num_rows($objQuery);$i++) {
	$result = mysql_fetch_array($objQuery);
	array_push($resultData,$result);

	if($result['mail_authorizedDate'] == "0000-00-00 00:00:00"){
		$result['mail_authorizedDate'] = "";
	}
	if($result['mail_requestUserDate'] == "0000-00-00 00:00:00"){
		$result['mail_requestUserDate'] = "";
	}
	if($result['mail_staffITdate'] == "0000-00-00 00:00:00"){
		$result['mail_staffITdate'] = "";
	}
	if($result['mail_authorizedConDate'] == "0000-00-00 00:00:00"){
		$result['mail_authorizedConDate'] = "";
	}
	if($result['mail_supervisorDate'] == "0000-00-00 00:00:00"){
		$result['mail_supervisorDate'] = "";
	}
}
//************************//
$pdf->AddPage('P','A4');
$pdf->SetAutoPageBreak(true , 5);
$pdf->AddFont('browallia','','browa.php');
$pdf->AddFont('browallia','B','browab.php');
$pdf->AddFont('browallia','I','browai.php');
$pdf->AddFont('browallia','BI','browaz.php');
$pdf->SetFont('browallia','B',15);
$pdf->SetFillColor(194,194,194);
$pdf->Cell(190,7,iconv('UTF-8','TIS-620','ใบทะเบียนประวัติเจ้าหน้าที่'),1,1,'C',true);
$pdf->Ln(7);
$pdf->AddFont('browallia','','browa.php');
$pdf->Cell(37,7,iconv('UTF-8','TIS-620','Employee ID : '),1,0,'R');
$pdf->Cell(55,7,iconv('UTF-8','TIS-620',''.$_GET['emp_id']),1,0,'C');
$pdf->Cell(6,7,iconv('UTF-8','TIS-620',''),0,0,'R');
$pdf->Cell(37,7,iconv('UTF-8','TIS-620','Department : '),1,0,'R');
$pdf->Cell(55,7,iconv('UTF-8','TIS-620',''.$result['emp_department']),1,1,'C');

$pdf->Cell(37,7,iconv('UTF-8','TIS-620','Name (ENG) : '),1,0,'R');
$pdf->Cell(55,7,iconv('UTF-8','TIS-620',''.$result['emp_nameEng']),1,0,'C');
$pdf->Cell(6,7,iconv('UTF-8','TIS-620',''),0,0,'R');
$pdf->Cell(37,7,iconv('UTF-8','TIS-620','Name (TH) : '),1,0,'R');
$pdf->Cell(55,7,iconv('UTF-8','TIS-620',''.$result['emp_nameTh']),1,1,'C');

$pdf->Cell(37,7,iconv('UTF-8','TIS-620','Surname (ENG) : '),1,0,'R');
$pdf->Cell(55,7,iconv('UTF-8','TIS-620',''.$result['emp_surnameEng']),1,0,'C');
$pdf->Cell(6,7,iconv('UTF-8','TIS-620',''),0,0,'R');
$pdf->Cell(37,7,iconv('UTF-8','TIS-620','Surname (TH) : '),1,0,'R');
$pdf->Cell(55,7,iconv('UTF-8','TIS-620',''.$result['emp_nameTh']),1,1,'C');

$pdf->Cell(37,7,iconv('UTF-8','TIS-620','Strat Date : '),1,0,'R');
$pdf->Cell(55,7,iconv('UTF-8','TIS-620',''.$result['emp_startDate']),1,1,'C');

$pdf->Ln(3);

$pdf->Cell(37,7,iconv('UTF-8','TIS-620','Username : '),1,0,'R');
$pdf->Cell(55,7,iconv('UTF-8','TIS-620',''.$result['mail_username']),1,0,'C');
$pdf->Cell(6,7,iconv('UTF-8','TIS-620',''),0,0,'R');
$pdf->Cell(37,7,iconv('UTF-8','TIS-620','By Request : '),1,0,'R');
$pdf->Cell(55,7,iconv('UTF-8','TIS-620',''.$result['mail_request']),1,1,'C');

$pdf->Cell(55,7,iconv('UTF-8','TIS-620',''.$result['mail_local']),1,0,'C');
$pdf->Cell(37,7,iconv('UTF-8','TIS-620','@admail.local'),1,0,'L');
$pdf->Cell(6,7,iconv('UTF-8','TIS-620',''),0,0,'R');
$pdf->Cell(37,7,iconv('UTF-8','TIS-620','Date/Time : '),1,0,'R');
$pdf->Cell(55,7,iconv('UTF-8','TIS-620',''.$result['mail_requestDate']),1,1,'C');

$pdf->Cell(55,7,iconv('UTF-8','TIS-620',''.$result['mail_coth']),1,0,'C');
$pdf->Cell(37,7,iconv('UTF-8','TIS-620','@adinop.co.th'),1,0,'L');
$pdf->Cell(6,7,iconv('UTF-8','TIS-620',''),0,0,'R');
$pdf->Cell(37,7,iconv('UTF-8','TIS-620','By Authorized : '),1,0,'R');
$pdf->Cell(55,7,iconv('UTF-8','TIS-620',''.$result['mail_authorized']),1,1,'C');

$pdf->Cell(37,7,iconv('UTF-8','TIS-620','Remark : '),1,0,'R');
$pdf->Cell(55,7,iconv('UTF-8','TIS-620',''.$result['mail_remark']),1,0,'C');
$pdf->Cell(6,7,iconv('UTF-8','TIS-620',''),0,0,'R');
$pdf->Cell(37,7,iconv('UTF-8','TIS-620','Date/Time : '),1,0,'R');
$pdf->Cell(55,7,iconv('UTF-8','TIS-620',''.$result['mail_authorizedDate']),1,1,'C');

$pdf->Ln(3);

$pdf->SetFillColor(0,0,0);
$pdf->Cell(92,0.5,iconv('UTF-8','TIS-620',''),1,0,'C',true);
$pdf->Cell(6,7,iconv('UTF-8','TIS-620',''),0,0,'R');
$pdf->Cell(92,0.5,iconv('UTF-8','TIS-620',''),1,1,'C',true);

$pdf->Ln(1);

$pdf->SetFillColor(194,194,194);
$pdf->Cell(92,7,iconv('UTF-8','TIS-620','For User Verify'),1,0,'C',true);
$pdf->Cell(6,7,iconv('UTF-8','TIS-620',''),0,0,'R');
$pdf->Cell(92,7,iconv('UTF-8','TIS-620','For IT Staff'),1,1,'C',true);

$pdf->Cell(37,7,iconv('UTF-8','TIS-620','By Request : '),1,0,'R');
$pdf->Cell(55,7,iconv('UTF-8','TIS-620',''.$result['mail_requestUser']),1,0,'C');
$pdf->Cell(6,7,iconv('UTF-8','TIS-620',''),0,0,'R');
$pdf->Cell(37,7,iconv('UTF-8','TIS-620','By Staff : '),1,0,'R');
$pdf->Cell(55,7,iconv('UTF-8','TIS-620',''.$result['mail_staffIT']),1,1,'C');

$pdf->Cell(37,7,iconv('UTF-8','TIS-620','Date/Time : '),1,0,'R');
$pdf->Cell(55,7,iconv('UTF-8','TIS-620',''.$result['mail_requestUserDate']),1,0,'C');
$pdf->Cell(6,7,iconv('UTF-8','TIS-620',''),0,0,'R');
$pdf->Cell(37,7,iconv('UTF-8','TIS-620','Date/Time : '),1,0,'R');
$pdf->Cell(55,7,iconv('UTF-8','TIS-620',''.$result['mail_staffITdate']),1,1,'C');

$pdf->Ln(3);

$pdf->SetFont('browallia','BU',15);
$pdf->Cell(190,7,iconv('UTF-8','TIS-620','Request Fulfillments'),1,1,'C',true);
$pdf->SetFont('browallia','B',15);

$pdf->Cell(37,7,iconv('UTF-8','TIS-620','By Authorized : '),1,0,'R');
$pdf->Cell(55,7,iconv('UTF-8','TIS-620',''.$result['mail_authorizedCon']),1,0,'C');
$pdf->Cell(6,7,iconv('UTF-8','TIS-620',''),0,0,'R');
$pdf->Cell(37,7,iconv('UTF-8','TIS-620','By Supervisor : '),1,0,'R');
$pdf->Cell(55,7,iconv('UTF-8','TIS-620',''.$result['mail_supervisor']),1,1,'C');

$pdf->Cell(37,7,iconv('UTF-8','TIS-620','Date/Time : '),1,0,'R');
$pdf->Cell(55,7,iconv('UTF-8','TIS-620',''.$result['mail_authorizedConDate']),1,0,'C');
$pdf->Cell(6,7,iconv('UTF-8','TIS-620',''),0,0,'R');
$pdf->Cell(37,7,iconv('UTF-8','TIS-620','Date/Time : '),1,0,'R');
$pdf->Cell(55,7,iconv('UTF-8','TIS-620',''.$result['mail_supervisorDate']),1,1,'C');

$pdf->SetFont('browallia','',12);
$pdf->Text(24,9.5,iconv("UTF-8", "ISO-8859-11","0000"),0,1,"C");
$pdf->Text(53,9.5,iconv("UTF-8", "ISO-8859-11","0000-00-00 00:00:00"),0,1,"C");
$pdf->Text(105,9.5,iconv("UTF-8", "ISO-8859-11","0000.0 00 0"),0,1,"C");

$pdf->Output();
?>